/*
 *  Copyright (C) 2011 glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.samples;

import javax.swing.JFrame;
import org.balisunrise.annotation.Menu;
import org.balisunrise.annotation.MenuAction;
import org.balisunrise.application.Application;
import org.balisunrise.application.Window;
import org.balisunrise.application.WindowsManager;
import org.balisunrise.builder.CommonFactory;
import org.balisunrise.builder.BuilderException;
import org.balisunrise.common.VisualEntity;
import org.balisunrise.common.VisualEntityType;

/**
 *
 * @author glauco
 */
@Menu
public class SampleMenu {

    private static final Application<JFrame> app;
    private static final WindowsManager windowsManager;
    private static final CommonFactory factory;
    
    static {
        app = Application.get();
        windowsManager = app.getWindowsManager();
        factory = app.getFactory();
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Locais",
        icon="",
        name="CadPais",
        text="Paises",
        toolTipText="Cadastro de Paises",
        index=100)
    public void cadastroPais(){
        try{
            //cria ve
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    Pais.class,
                    "");
            // cria view
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Locais",
        icon="",
        name="CadEstado",
        text="Estados",
        toolTipText="Cadastro de Estados",
        index=200)
    public void cadastroEstado(){
        try{
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    Estado.class,
                    "");
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Locais",
        icon="",
        name="CadCidade",
        text="Cidades",
        toolTipText="Cadastro de Cidades",
        index=300)
    public void cadastroCidade(){
        try{
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    Cidade.class,
                    "def");
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Locais",
        icon="",
        name="CadCEP",
        text="CEP's",
        toolTipText="Cadastro de CEP's",
        index=300)
    public void cadastroCEP(){
        try{
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    CEP.class,
                    "def");
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Pessoas",
        icon="",
        name="CadClienteP",
        text="Clientes Pessoa Física",
        toolTipText="Cadastro de Clientes Pessoa Física",
        index=100)
    public void cadastroClienteFisica(){
        try{
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    Cliente.class,
                    "def");
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }

    @MenuAction(
        module="Sample",
        folder="Cadastros/Pessoas",
        icon="",
        name="CadClienteJ",
        text="Clientes Pessoa Jurídica",
        toolTipText="Cadastro de Clientes Pessoa Jurídica",
        index=200)
    public void cadastroClienteJuridica(){
        try{
            VisualEntity ve = factory.createVisualEntity(
                    VisualEntityType.TRANSACTION,
                    Cliente.class,
                    "jur");
            Window window = windowsManager.createWindow(ve);
            windowsManager.showWindow(window);
        }catch(BuilderException ex){
            //log
        }
    }
}
